package com.anyonavinfo.cpaddemo.service.musicplayerservice;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;

import com.anyonavinfo.cpaddemo.data.musicinfo.MusicInfo;


public class MusicPlayerService extends Service {

	private MusicPlayerServiceHelper mPlayServiceHelper;

	public class MyBinder extends Binder {
		public MusicPlayerService getService() {
			return MusicPlayerService.this;
		}
	}

	@Override
	public void onCreate() {
		mPlayServiceHelper = MusicPlayerServiceHelper.getInstance();
	}

	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		return START_STICKY;
	}

	@Override
	public IBinder onBind(Intent intent) {
		return new MyBinder();
	}

	@Override
	public void onDestroy() {

	}


	public void onServiceConnected(){
		mPlayServiceHelper.onServiceConnected(this);
	}
	public void playMusic(MusicInfo musicInfo) {
		mPlayServiceHelper.play(musicInfo);
	}
	public void pauseMusic() {
		mPlayServiceHelper.pause();
	}
	public void stopMusic() {
		mPlayServiceHelper.stop();
	}
	public void changePlayProgress(int time){
		mPlayServiceHelper.changePlayProgress(time);
	}
}
